import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.CsvFileSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.stream.Stream;


public class JunitTest01 {

    public static Stream<Arguments> Good(){
        return Stream.of(Arguments.arguments("abc",1),Arguments.arguments("bac",2));
    }
    @Order(1)
@ParameterizedTest
    @CsvFileSource(resources = "test01.csv")
    public void test01(String listUrl){
     WebDriver webDriver = new ChromeDriver();
        webDriver.get("http://127.0.0.1:8080/blog_system/login.html");
        webDriver.findElement(By.name("username")).sendKeys("lisi");
        webDriver.findElement(By.id("password")).sendKeys("123");
        webDriver.findElement(By.xpath("//*[@id=\"submit\"]")).submit();
        String currentUrl = webDriver.getCurrentUrl();
        Assertions.assertEquals(listUrl,currentUrl);
}

@Test
public void test02(){
    System.out.println("abcd");
}
@BeforeEach

public void test03(){

    System.out.println("akk");
}


   @AfterEach
    public void test04(){
       System.out.println("这是test04测试");
   }

   @BeforeAll
    public static void test05(){
       System.out.println("这是test05测试");
   }
   @ParameterizedTest
    @ValueSource(strings = {"abc","coa"})
    public void test06(String num){
       System.out.println(num);
   }

   @ParameterizedTest
    @CsvFileSource(resources = "test05.csv")
    public void test07(String name,int num){
       System.out.println("name:"+name);
       System.out.println("num:"+num);
   }
   @ParameterizedTest
    @MethodSource("Good")
    public void test09(String name,int num){
       System.out.println(name+" "+num);
   }
}
